﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MeTV.MediaPortalService;

namespace MeTV
{
    public partial class EpgSearchForm : Form
    {
        public EpgSearchForm()
        {
            InitializeComponent();
        }

        private void buttonSearch_Click(object sender, EventArgs e)
        {
            listViewSearchResults.Items.Clear();
            WebProgram[] programs = Client.Instance.client.SearchEPG(textBoxSearch.Text.Trim());

            if (programs.Length == 0)
            {
                MessageBox.Show(this, "No search results", "Me TV - EPG Search");
            }
            else
            {
                foreach (WebProgram program in programs)
                {
                    ListViewItem item = listViewSearchResults.Items.Add(program.description);
                    item.SubItems[0].Text = program.description;
                    item.SubItems[1].Text = program.channelName;
                    item.SubItems[2].Text = program.startTime.ToString();
                    item.SubItems[3].Text = program.endTime.ToString();
                    item.Tag = program;
                }
            }
        }
    }
}
